/**
 * 
 */
package com.jquery.ui.tags.javascript.tab;

import com.jquery.ui.core.base.BaseTag;
import com.jquery.ui.core.bean.UIBean;
import com.jquery.ui.core.exception.JqueryUIRuntime;
import com.jquery.ui.tags.beans.script.TabScriptUI;
import com.jquery.ui.tags.beans.script.TabsScriptUI;
import com.jquery.ui.tags.javascript.tabs.TabsTag;

/**
 * @author linyajun
 * 
 * @date	2013-9-24
 * @description   
 */
public class TabTag extends BaseTag {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5780800674264148711L;

	private String title;
	private Boolean showClose=false;
	private String href;
	private String uuId;
	@Override
	public String getEndTemplate() {
		
		return null;
	}

	
	@Override
	public String getStartTemplate() {
		
		return "tab-script.ftl";
	}

	
	@Override
	public UIBean getUiBean() {
		TabScriptUI ui=new TabScriptUI();
		ui.setTitle(title);
		ui.setUuId(uuId);
		ui.setShowClose(showClose);
		ui.setHref(href);
		return ui;
	}
	
	
	@Override
	protected boolean isValid() {
		TabsTag tabsTag=(TabsTag)findAncestorWithClass(this, TabsTag.class);
		if (tabsTag==null) {
			throw new JqueryUIRuntime("The tab tag must be wrapped in Tabs Tags! please check!");
		}
		uuId=((TabsScriptUI)(tabsTag.getUiBean())).getUuId();
		return super.isValid();
	}


	

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}


	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}


	/**
	 * @return the showClose
	 */
	public Boolean getShowClose() {
		return showClose;
	}


	/**
	 * @param showClose the showClose to set
	 */
	public void setShowClose(Boolean showClose) {
		this.showClose = showClose;
	}


	/**
	 * @return the href
	 */
	public String getHref() {
		return href;
	}


	/**
	 * @param href the href to set
	 */
	public void setHref(String href) {
		this.href = href;
	}
	
	

}
